package com.mask.userprovider;


import com.mask.userapi.UserApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicInteger;

@RestController
public class UserController  implements UserApi {

    @Value("${server.port}")
    String port;

    private AtomicInteger count = new AtomicInteger();

    @Override
    public String alive() {
        try {
            System.out.println("准备睡");
            Thread.sleep(1000);
        }catch (Exception e){
            e.printStackTrace();
        }
        int i = count.getAndIncrement();
        System.out.println(port+"===第:"+i+"次调用");
        return "provider:port" + port;
    }

    @Override
    public String getById(String name) {
        return "getById"+name;
    }

//    @GetMapping(value = "/alive")
//    public String alive(){
//        return "ok";
//    }


}
